<include file="Common/head" />
<link rel="stylesheet" href="__PUBLIC__/css/weixin/iconfont.css">
<link rel="stylesheet" href="__PUBLIC__/css/weixin/consult.css" />
<div class="mui-content mui-scroll-wrapper pb50">
    <div class="mui-scroll">
        <div class="consult-item">
            <header class="consult-head">
                <div class="avatar-middle">
                    <img src="{$consult.consult_id|getAvatar}" class="uhimg">
                </div>
                <div class="cont">
                    <div class="name">{$consult.title}</div>
                    <div class="time">{$consult.consult_time|date='Y-m-d H:i',###}</div>
                </div>
            </header>
            <p class="consult-text break-all f-grey2">{$consult.content}</p>
        </div>
        <div id="comment-list">
        </div>
    </div>
</div>
<!--评论-->
<!--nav id="pingFoot" class="mui-bar mui-foot">
    <div class="layout-box">
        <textarea class="flex-item1" id="txt-publisher" placeholder="说点什么吧..."></textarea>
        <button type="button" id="sendBtn" class="btn-default">发送</button>
    </div>
    <div class="hide clearfix" id="face_con">

    </div>
</nav-->
<script type="text/javascript">
    var curPage = 1;
    var data = {$reply};
    var consult = {$consult};
    var consult_id = "{$consultId}";
    (function($) {
        $.init();
        if (data.length > 0) {
            var html = '';
            mui.each(data, function (index, item) {
                html += '<div class="comment-item">';
                html += '<div class="avatar-middle"><img src="'+item.avatar+'" class="uhimg"></div>';
                html += '<div class="lh15 clearfix"><span class="name fl">系统管理员</span><span class="time fr">'+baseTool.formatDate(item.reply_time,"MM-dd h:m")+'</span></div>';  //'+item.replyName+'
                html += '<div class="text">'+item.content+'</div></div>';
            });
            document.getElementById("comment-list").innerHTML = html;
        }
        if(consult.status == '3'){
            $('#txt-publisher').hide();
            $('#sendBtn').hide();

        }
        document.getElementById("sendBtn").addEventListener('tap', function() {
            doReply();
        });
    })(mui);

    function doReply() {
        var content = $("#txt-publisher").val();//document.getElementById("txt-publisher").innerHTML;
        if (content) {
            mui.ajax(apiUrl+'/Consulting/doReply',{
                data:{
                    consult_id: consult_id,
                    content: content
                },
                dataType: 'json',//服务器返回json格式数据
                type: 'post',//HTTP请求类型
                success: function(cbData){
                    if (cbData.code == 200) {
                        $("#txt-publisher").val("");
                        var html = '';
                        html += '<div class="comment-item">';
                        html += '<div class="avatar-middle"><img src="'+cbData.data.avatar+'" class="uhimg"></div>';
                        html += '<div class="lh15 clearfix"><span class="name fl">'+cbData.data.replyName+'</span><span class="time fr">'+baseTool.formatDate(cbData.data.reply_time,"MM-dd h:m")+'</span></div>';
                        html += '<div class="text">'+cbData.data.content+'</div></div>';
                        if($("#comment-list").length>0){
                            $("#comment-list").append(html);
                        }else{
                            $("#comment-list").html(html);
                        }

                    }

               }
            });
        }

    }

    mui.init();

    mui('.mui-scroll-wrapper').scroll({
        deceleration: 0.0005 //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006
    });

    mui.plusReady(function() {

    })
</script>
<include file="Common/footer" />